#include "cprotocole.h"

CProtocole::CProtocole(QObject *parent) :
    QObject(parent)
{
    this->rx_index = 0U;
    this->rx_state = E_RX_STATE_IDLE;
}

unsigned char CProtocole::CalculateCHK( unsigned char *p_data, unsigned char length )
{
    unsigned char loop;
    unsigned char c_chk = length+1U;

    for( loop=0; loop<length; loop++ )
    {
        c_chk += p_data[loop];
    }

    c_chk = ~c_chk;
    c_chk += 1U;

    return c_chk;
}
